package com.exam.utils;

import java.util.Map;

import com.exam.bean.Sex;
import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;

public class SexConverter extends DefaultTypeConverter {

	@SuppressWarnings("unchecked")
	@Override
	public Object convertValue(Map<String,Object> context,Object value, Class toType) {
		try {
			if(toType==Sex.class){
				return Sex.valueOf((String)value);
			}
			else if(toType==String.class){
				return ((Sex)value).toString();
			}
		}catch (Exception e) {}
		return null;
	}

}
